Sets the default path that this Group is associated with. This path is the directory that the 'Add Items' panel will automatically be set to, and it is the path used for relative dynamicItems specifiers.
Add a new file type (e.g. .h, .m, .snd) to the list of allowed types for this group
*/
{
NXAtom a = NXUniqueString ( anExt );
if ( [typesList indexOfAtom:a] == NX_NOT_IN_LIST ) {
[typesList addAtomAlphabetically:a];
restrictTypes = YES; // Enable restrictions
[self setChanged:YES];
}
return ( self );
}
- removeAllowedType:(const char *)anExt
/*
Remove the specified type from the typesList
*/
{
if ( [typesList indexOfAtom:NXUniqueString(anExt)] != NX_NOT_IN_LIST ) {
[typesList removeAtom:NXUniqueString(anExt)];
[self setChanged:YES];
}
return ( self );
}
- setRestrictTypes:(BOOL)flag
/*
Set the restrictTypes flag
*/
{
if ( restrictTypes != flag ) {
restrictTypes = flag;
[self setChanged:YES];
}
return ( self );
}
- (const char **)allowedTypes
/*
Returns a NULL-terminated array of strings containing the allowed file types for this group. This array is rebuilt each time this method is called. The caller shouldn't keep the returned array around, as it will be freed
*/
{
static const char **allowedTypes = NULL;
int i, count = 0;
if ( allowedTypes ) { // Free previously allocated memory
NX_FREE ( allowedTypes );
allowedTypes = NULL;
}
// Allocate memory for array
// Array must be big enough for all types + NULL pointer
static int compareItems ( ItemCell **item1, ItemCell **item2 )
/*
Compares the items for sorting, based on their filenames ( the last component of the item's path ). Comparison is NOT case-sensitive. This functions is used by the qsort() routine.
Sort the items in currentGroup alphabetically by filename ( last component of path ). Uses qsort() to do this. Qsort() calls our comparison function, compareItems(), and the directly reorders them in the dataPtr array.
*/
{
if ( [self doesSortItems] || needsSort ) {
// Qsort()'s parameters are:
// 1. pointer to beginning of data -- in this case, dataPtr
// 2. number of elements to be sorted -- numElements
[self errMsg:"Group: unrecognized version %i of archived object!\n",
versionNumber];
}
return ( self );
}
- write:(NXTypedStream *)stream
/*
Overrides standard archiving behavior of List to deal with Dynamic Items. We must make sure that the archived count is the number of static items (non-dynamic), since DynamicItems don't get archived.
*/
{
unsigned int i, count;
// First, set numElements to 0 to make [super write:] think there is nothing to write
count = numElements;
numElements = 0;
// Now let super do it's thing....
[super write:stream];
// Restore numElements
numElements = count;
// Archive all of the items ourselves
count -= [self countDynamicItems]; // actual num. of items being archived
NXWriteType ( stream, "i", &count );
for ( i=0; i<numElements; i++ )
if ( ![dataPtr[i] isDynamic] ) NXWriteObject ( stream, dataPtr[i] );